package com.ml.mall.mapper.variant;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ml.mall.bean.req.product.*;
import com.ml.mall.bean.req.product.vo.ProductVariantShopVO;
import com.ml.mall.bean.res.product.SysProductQueryByRandomWith18Res;
import com.ml.mall.bean.res.product.SysProductQueryTreeRes;
import com.ml.mall.bean.res.product.SysProductShopPageRes;
import com.ml.mall.bean.res.variant.SysProductVariantQueryAllRes;
import com.ml.mall.bean.res.variant.SysProductVariantQueryCartRes;
import com.ml.mall.bean.vo.variant.VariantCountVO;
import com.ml.mall.bean.vo.variant.VariantDetailVO;
import com.ml.mall.entity.industry.Industry;
import com.ml.mall.entity.product.SysProduct;
import com.ml.mall.entity.variant.SysProductVariant;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author kyyang
* Created 2021-05-15
*/
@Repository
public interface SysProductVariantMapper extends BaseMapper<SysProductVariant> {
    //查询个时间之前的变体价格
    SysProductVariant selectTimeBeforeData(@Param("variantId") Long variantId,@Param("timeEnd") String timeEnd);
    //variantId 查询产品信息
    List<ProductVariantShopVO> selectVariantByProductId(@Param("productId") Long productId);
    //variantId 查询产品信息
    SysProduct  selectProductByVariantId(@Param("variantId") Long variantId);

    VariantDetailVO selectRelationDetail(@Param("variantId") Long variantId);

    List<SysProductVariantQueryAllRes> selectVariantByProduct(@Param("productId") Long productId);

    List<SysProductQueryTreeRes> sysProductQueryTree(@Param("productId") Long productId);

    @Select("select max(ver_id) from sys_product_variant where variant_id = #{variantId}")
    int selectMaxVerId(@Param("variantId") Long variantId);

    /**
     * @description 产品搜索:按照关键词以及州属进行分页,查询产品信息
     * @author pl
     * @date 2021/6/30
     */

    List<SysProductShopPageRes> queryProductVariant(@Param("dto") ShopQueryPageByKeyWord dto);

    /**
     * @description 产品搜索:按照keyWord以及statesCanSend进行分页,查询数据库中符合条件的数量
     * @author pl
     * @date 2021/6/30
     */
    int queryProductVariantExistsCounts(@Param("dto") ShopQueryPageByKeyWord dto);

    /**
     * @description 产品搜索:按照categoryId进行分页,查询经过排序之后的产品信息
     * @author pl
     * @date 2021/6/30
     */
    List<SysProductShopPageRes> queryVariantByCategoryId(@Param("dto") ShopQueryPageByCategoryIdDto dto);

    /**
     * @description 产品搜索:按照categoryId进行分页,查询对应分页查询结果数量
     * @author pl
     * @date 2021/6/30
     */
    Integer queryVariantNumByCategoryId(@Param("dto") ShopQueryPageByCategoryIdDto dto);

    /**
     * @description 产品搜索:随机查询18条促销产品
     * @author pl
     * @date 2021/7/1
     */
    List<SysProductQueryByRandomWith18Res> queryVariantByRandomWith18(@Param("dto") QueryRandom18Dto dto);


    /**
     * @description 产品搜索:按照supplierId并排序后查询卖家下的产品信息
     * @author pl
     * @date 2021/7/1
     */
    List<SysProductShopPageRes> queryVariantBySupplierId(@Param("dto") ShopQueryPageBySupplierIdDto dto);

    /**
     * @description 产品搜索:按照supplierId进行分页,查询对应分页查询结果数量
     * @author pl
     * @date 2021/7/1
     */
    Integer queryVariantNumBySupplierId(@Param("dto") ShopQueryPageBySupplierIdDto dto);

    Industry selectIndustryByVariantId(@Param("variantId") Long variantId);

    /**
     * @description 产品搜索:按照variantId查找categoryId
     * @author pl
     * @date 2021/7/2
     */
    String sysCategoryIdByVariantId(@Param("dto") SysVariantIdDto dto);

    /**
     * @description 产品搜索:按照variantId查找到的categoryId查询SysProductVariant
     * @author pl
     * @date 2021/7/2
     */
    List<SysProductShopPageRes> sys12VariantByCategoryId(@Param("categoryId") String categoryId);


    /**
     * @description: 查询 variant 数量
     *
     * @author kyyang
     * @date 2021/8/7 16:49
     * @version 1.0
     */
    VariantCountVO selectVariantCount();

    SysProductVariant getSysProductVariant(Long id);

    SysProductVariantQueryCartRes getSysVariantRes(@Param("variantId") Long variantId);


    List<SysProductVariantQueryCartRes> getVariantByList(@Param("variantIdList") List<Long> variantIdList);
}

